<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test01</title>
</head>
<body>
<script type="text/javascript">
    class Person {
        static foo = 'bar';

        _name_counter = 0;

        constructor(name, age) {
            this.name = name;
            this.age = age;
            // this.sayName = this.sayName.bind(this);
        }

        // sayName() {
        //     console.log(this.name);
        // }

        sayName = () => console.log(this.name);

        static sayFoo() {
            // console.log(Person.foo);
            console.log(this.foo);
        }

        get name() {
            console.log("Getter");
            this._name_counter++;
            return this._name;
        }

        set name(val) {
            console.log("Setter:" + val);
            this._name = val;
        }
    }

    let p01 = new Person("zhangsan", 18);
    p01.sayName();
    p01.sayName();
    p01.sayName();
    p01.sayName();
    p01.sayName();
    p01.sayName();
    p01.sayName();
    p01.sayName();

    console.log(p01._name_counter);

</script>
</body>
</html>